package org.bee.service.ext;

import org.bee.enums.IsDelete;
import org.bee.mappers.DictMapper;
import org.bee.mappers.ext.DictExtMapper;
import org.bee.model.Dict;
import org.bee.model.DictExample;
import org.bee.model.DictSelect;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DictExtService {

    private final DictExtMapper dictExtMapper;

    private final DictMapper dictMapper;

    public DictExtService(DictExtMapper dictExtMapper, DictMapper dictMapper) {
        this.dictExtMapper = dictExtMapper;
        this.dictMapper = dictMapper;
    }
    public List<DictSelect> getDictDetails(Dict dict, String label, String value) {
        return dictExtMapper.getDictDetails(dict, label, value);
    }

    public List<Dict> selectDict(String dictCode) {
        DictExample dictExample = new DictExample();
        DictExample.Criteria criteria = dictExample.createCriteria();
        criteria.andDictCodeEqualTo(dictCode);
        criteria.andIsDeletedEqualTo(Boolean.valueOf(IsDelete.FALSE.getCode()));
        return dictMapper.selectByExample(dictExample);
    }
}
